package la.iok.hzsvn.lewin.movie.controller;

import la.iok.hzsvn.lewin.movie.core.Token;
import la.iok.hzsvn.lewin.movie.entity.HolidayConfig;
import la.iok.hzsvn.lewin.movie.service.HolidayConfigService;
import la.iok.hzsvn.share.response.ListDataResponse;
import la.iok.hzsvn.share.response.OperatorResponse;
import la.iok.hzsvn.share.response.OperatorResponses;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("holiday")
public class HolidayController {
    private final HolidayConfigService holidayConfigService;

    public HolidayController(HolidayConfigService holidayConfigService) {
        this.holidayConfigService = holidayConfigService;
    }

    @PostMapping
    public OperatorResponse save(@RequestHeader Token token, String date, Integer type){
        holidayConfigService.save(token, date, type);
        return OperatorResponses.success();
    }

    @GetMapping
    public ListDataResponse<HolidayConfig> load(String date){
        return new ListDataResponse<>(holidayConfigService.list(date));
    }
}
